#coding=utf-8
__author__ = 'yanhaijiang'

# 参照廖雪峰的官方网站
# name = raw_input('please enter your name: ')
# print ord('A')
# classmates = ['Michael', 'Bob', 'Tracy']
# classmates.pop()
# print len(classmates)
# print classmates[1]
#
# t = ('a', 'b', ['A', 'B'])
# t[2][0] = 'X'
# t[2][1] = 'Y'
# print t


# age = 20
# if age >= 18:
#     print 'your age is', age
#     print 'adult'
#
# print '......'
#
# names = ['Michael', 'Bob', 'Tracy']
# for name in names:
#     print name
#
# sum = 0
# n = 99
# while n > 0:
#     sum = sum + n
#     n = n - 2
# print sum

# birth = int(raw_input('birth: '))
# if birth < 2000:
#     print '11'
# else:
#     print '22'

# dict set


# d = {'Michael': 95, 'Bob': 75, 'Tracy': 85}
# print d['Michael']  # 95
# print 'Thomas' in d  # false
# print d.get('Thomas')  # None
# print d.get('Thomas', -1)  # -1
#
# d.pop('Bob')
# print d  # {'Michael': 95, 'Tracy': 85}


# set

# # s = set([1, 2, 3])
# s = set([1, 1, 2, 2, 3, 3])
#
# # add(key)
# s.add(4)
# s.remove(4)
# print s

# a = ['c', 'b', 'a']
# a.sort()
# print a  # ['a', 'b', 'c']

# a = 'abc'
# b = a.replace('a', 'A')
# print b  #  Abc

# function
#
# print abs(12.34)
# # 比较函数
# print cmp(1, 2)  # -1
# print cmp(2, 1)  # 1
# print cmp(3, 3)  # 0
#
# # 数据类型转换
# print int('123')
# print int(12.34)
# print float('12.34')
# print str(1.23)
# print bool(1)

# 定义函数
# def my_abs(x):
#     if x >= 0:
#         return x
#     else:
#         return -x
#
# def nop():
#     pass
#
#
# print my_abs(222)
#
#
# import math
#
# def move(x, y, step, angle=0):
#     nx = x + step * math.cos(angle)
#     ny = y - step * math.sin(angle)
#     return nx, ny
#
# x, y = move(100, 100, 60, math.pi / 6)
# print x, y
#
# r = move(100, 100, 60, math.pi / 6)
# print r

# def power(x):
#     return x * x
# print power(5)  # 25
#
# def power(x, n):
#     s = 1
#     while n > 0:
#         n = n - 1
#         s = s * x
#     return s
# print power(5, 2)  # 25

# def enroll(name, gender):
#     print 'name:', name
#     print 'gender:', gender
#
# enroll('Sarah', 'F');
# print '...............'
# def enroll(name, gender, age=6, city='Beijing'):
#     print 'name:', name
#     print 'gender:', gender
#     print 'age:', age
#     print 'city:', city
# enroll('Sarah', 'F');

# 默认参数   最大的坑
# def add_end(L=[]):
#     L.append('END')
#     return L
#
# print add_end([1, 2, 3])
# print add_end()
# print add_end()
# 改进
# def add_end(L=None):
#     if L is None:
#         L = []
#     L.append('END')
#     return L
#
# print add_end()
# print add_end()

# 计算a2 + b2 + c2 + ……
# def calc(numbers):
#     sum = 0
#     for n in numbers:
#         sum = sum + n * n
#     return sum
# print calc([1, 2, 3])

def calc(*numbers):
    sum = 0
    for n in numbers:
        sum = sum + n * n
    return sum

print calc(1, 2)
nums = [1, 2, 3]
print calc(nums[0], nums[1], nums[2])

nums = [1, 2, 3]
print calc(*nums)